const TokenKey = 'token'

export function getToken() {
  return localStorage.getItem(TokenKey)
}

export function setToken(token) {
  return localStorage.setItem(TokenKey, token)
}

export function removeToken() {
  return localStorage.removeItem(TokenKey)
}

const UserInfoKey = 'userInfo'
export function getUserInfo() {
  let value = localStorage.getItem(UserInfoKey) || null
  if (value) {
    value = JSON.parse(value)
  }
  return value || {}
}

export function setUserInfo(data) {
  return localStorage.setItem(UserInfoKey, JSON.stringify(data))
}

export function removeUserInfo() {
  return localStorage.removeItem(UserInfoKey)
}

const MenuKey = 'menuList'
export function getMenuList() {
  let value = localStorage.getItem(MenuKey) || null
  if (value) {
    value = JSON.parse(value)
  }
  return value || {}
}

export function setMenuList(data) {
  return localStorage.setItem(MenuKey, JSON.stringify(data))
}

export function removeMenuList() {
  return localStorage.removeItem(MenuKey)
}
